import { Button } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import { PartitionOutlined } from '@ant-design/icons';

const columns = (onRowNumberClick: (record: any) => void) => {
  const columns: ColumnsType<any> = [
    {
      title: '#',
      dataIndex: 'id',
      key: '__row_number',
      align: 'right',
      width: 48,
      render: (text, record, index) => {
        return (
          <Button
            type="link"
            style={{ padding: 0 }}
            onClick={() => onRowNumberClick(record)}
          >
            <em>{index + 1}</em>
          </Button>
        );
      }
    },
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
      render: (text, record, index) => {
        return record.parentId ? text : <strong>{text}</strong>;
      }
    },
    {
      title: '省份',
      dataIndex: 'provinceName',
      key: 'provinceName',
      render: (text, record, index) => {
        return text ? text : <PartitionOutlined />;
      }
    },
    {
      title: '序号',
      dataIndex: 'cityNumber',
      key: 'cityNumber',
      align: 'right'
    }
  ];
  return columns;
};

export default columns;
